#include <stdio.h>

#define MAX 300

int main(int argc, char *argv[])
{
	int a[MAX], b, c, total[MAX], id[MAX], n;
	int i, j, t;

	scanf("%d", &n);
	for (i=0; i<n; i++) {
		scanf("%d %d %d", &a[i], &b, &c);
		total[i] = a[i] + b + c;
		id[i] = i + 1;
	}

	for (i=0; i<n-1; i++) {
		for (j=i+1; j<n; j++) {
			if ((total[j] > total[i]) ||
				(total[j] == total[i] && a[j] > a[i]) ||
				(total[j] == total[i] && a[j] == a[i] && id[j] < id[i])) {
				t = total[j]; total[j] = total[i]; total[i] = t;
				t = a[j]; a[j] = a[i]; a[i] = t;
				t = id[j]; id[j] = id[i]; id[i] = t;
			}
		}
	}

	for (i=0; i<5; i++) {
		printf("%d %d\n", id[i], total[i]);
	}

	return 0;
}
